
def p2(f):
    u=2
    d=1
    return 2*u/(1+2*u*f) - 2*d/(1-2*d*f) + 2*(u-d)/(1+(u-d)*f)

def p3(f):

    return 6/(1+6*f) + 9/(1+3*f) - 3/(1-3*f)

#c
dis = 1e10
right_f = 0
for f in range(0,500):
    if p2(f/1000.0)<dis and p2(f/1000.0) > 0:
       right_f = f/1000.0
       dis = p2(f/1000.0)
print(right_f) 

#D
dis = 1e10
right_f = 0
for f in range(0,333):
    if p3(f/1000.0)<dis and p3(f/1000.0) > 0:
       right_f = f/1000.0
       dis = p3(f/1000.0)
print(right_f) 